(() => {
  /**
   * 内置对象类型
   * --- Boolean、Number、string、RegExp、Date、Error
   */

  /**
   * Boolean:传参any; 
   * 除了false、0、-0、0n（BigInt类型的0）、""（空字符串）、null、undefined、NaN以外，其它均会被转换为true
   */
  let b: Boolean = new Boolean(1);
  console.log(b); // true
  let b1: Boolean = new Boolean('ded');
  console.log(b1); // true
  /**
   * Number:传参any; 
   * 除了Infinity、-Infinity以外，其它均会被转换为Number类型
   * boolean给1，0；null给0；undefined给NaN；string、symbol、object给NaN
   */
  let n: Number = new Number(true)
  console.log(n);  // 1
  let n1: Number = new Number(undefined)
  console.log(n1); // NaN
  let n2: Number = new Number(null)
  console.log(n2); // 0
  let n3: Number = new Number('under')
  console.log(n3); // NaN
  let n4: Number = new Number(NaN)
  console.log(n4);  // NaN
  let n5: Number = new Number(Infinity)
  console.log(n5);  // Infinity
  /**
   * String:传参any; 
   * 传任意值均会被转换为字符串类型
   */
  let s: String = new String(123)
  console.log(s); // "123"
  let s1: String = new String(undefined)
  console.log(s1); // "undefined"
  let s2: String = new String(null)
  console.log(s2); // "null"
  let s3: String = new String(true)
  console.log(s3); // "true"
  let s4: String = new String({ name: 'chenfeng' })
  console.log(s4); // "[object Object]"
  /**
   * RegExp:传参string; 
   * 用于匹配字符串
   */
  let re: RegExp = new RegExp('abc')
  console.log(re); // /abc/
  let re1: RegExp = new RegExp('abc', 'i')
  console.log(re1); // /abc/i
  /**
   * Date:传参number、string、Date; 
   * 用于处理日期和时间
   */
  let d: Date = new Date(2021, 11, 12)
  let d1: Date = new Date('2021-12-12')
  let d2: Date = new Date(d)
  /**
   * Error:传参string; 
   * 用于处理错误信息
   */
  let e: Error = new Error('error')
  console.log(e); // Error: error

  /**
   * promise: 泛型参数类型
   * Promise<T>接口，T表示Promise的泛型参数类型，可以是任意类型。
   */
  function promise(): Promise<number> {
    return new Promise<number>((resolve, reject) => {
      resolve(1)
    })
  }
  promise().then(res => {
    console.log(res);
  })
})();

